import * as crypto from 'crypto';
/**
 * 对内容单向加密
 * @param algorithm 算法 md5|sha1 Creates and returns a Hash object that can be used to generate hash digests using the given algorithm. Optional options argument controls stream behavior.The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha256', 'sha512', etc. On recent releases of OpenSSL, openssl list -digest-algorithms (openssl list-message-digest-algorithms for older versions of OpenSSL) will display the available digest algorithms. 文档：http://nodejs.cn/api/crypto.html#crypto_crypto_createhash_algorithm_options
 * @param content 内容
 * @example hash(algorithm,content);
 */
export default function hash(algorithm: 'md5' | 'sha1', content: string) {
	return crypto.createHash(algorithm).update(content).digest('hex');
}
